<template>
    <div class="m-25 mt-65">
        <div class="normal-box-mod">
            <div class="normal-box-hd clearfix">
                <div class="normal-box-title">
                    <div class="decorate-square"/>
                    <h2>出库订单</h2>
                </div>
            </div>
            <div class="normal-box-bd">
                <div class="normal-list-page-mod">
                    <div class="normal-list-page-bd">
                        <Table border :loading="list.loading" :columns="list.columns" :data="list.tableData" @on-selection-change="selectionChange"></Table>
                    </div>
                    <div class="normal-list-page-ft clearfix">
                        <Page class="fr" :total="queryData.totalRecord" :page-size="queryData.pageSize" :current="queryData.page" @on-change="changePage" @on-page-size-change="onPageSizeChange" show-total show-elevator show-sizer></Page>
                    </div>
                </div>

            </div>
        </div>
    </div>
</template>
<script>
import CoDeliveryGoodsApi from '@/api/zhcg/CoDeliveryGoods.js'
import moment from 'moment'
import { Message } from 'iview'

export default {
  name: 'coDeliveryGoods',
  data () {
    return {
      // 列表
      list: {
        loading: false,
        selections: [],
        // 列表展示数据
        tableData: [],
        // 表格表头
        columns: [
          /** 开始自动生成 */
          { title: '出库单号', minWidth: 120, align: 'center', key: 'id' },
          { title: '厂名', minWidth: 120, align: 'center', key: 'name' },
          { title: '品类', minWidth: 120, align: 'center', key: 'goodsName' },
          { title: '净重(kg)', minWidth: 120, align: 'center', key: 'netWeight' },
          { title: '价格(元/kg)', minWidth: 120, align: 'center', key: 'price' },
          // { title: '费用', align: 'center', key: 'expense' },
          { title: '应收款(元)', minWidth: 120, align: 'center', key: 'receipts' },
          { title: '实际收款(元)', minWidth: 120, align: 'center', key: 'actualReceipts' },
          // {title: "分拣站点ID",align:'center', key: "stationId"},
          { title: '支付状态',
            minWidth: 120,
            align: 'center',
            key: 'payStatus',
            render: (h, params) => {
              if (params.row.payStatus === 0) {
                return h('div', '未支付')
              } else if (params.row.payStatus === 1) {
                return h('div', '已支付')
              }
            }
          },
          // { title: '扣点', align: 'center', key: 'weightRate' },
          // { title: '扣重', align: 'center', key: 'subWeight' },
          { title: '车牌号', minWidth: 120, align: 'center', key: 'licensePlateNumber' },
          { title: '出库时间',
            minWidth: 200,
            align: 'center',
            key: 'deliveryTime',
            render: (h, params) => { return h('div', moment.unix(params.row.deliveryTime / 1000).format('YYYY-MM-DD HH:mm:ss')) }
          }
          /** 自动生成结束 */
        ]
      },
      // 页面查询数据
      queryData: {
        limit: 10,
        page: 1,
        totalRecord: 0
      }
    }
  },
  methods: {

    // 获取列表
    getTableData () {
      const that = this
      that.list.loading = true
      CoDeliveryGoodsApi.getPageList(that.queryData)
        .then(res => {
          that.list.tableData = res.data.list
          that.queryData.totalRecord = res.data.totalRecord
          that.list.loading = false
          that.queryData.limit = res.data.pageSize
        })
        .catch(error => {
          Message.error(error)
        })
    },

    // 换页
    changePage (page) {
      this.queryData.page = page
      this.getTableData()
    }

  },

  created () {
    this.getTableData()
  }
}
</script>
